package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.PostBean;
import com.project.mapper.IPostMapper;
import com.project.service.IPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.swing.*;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Service
@Transactional
public class PostServiceImpl implements IPostService {
    @Autowired
    private IPostMapper mapper;
    @Override
    public void add(PostBean post) {
        mapper.add(post);
    }

    @Override
    public PageInfo<PostBean> findByItem(int id, int pageNo, String postName, String userName, LocalDateTime startDate, LocalDateTime endDate) {
        PageHelper.startPage(pageNo,PAGSIZE);
        PageInfo<PostBean> info = PageInfo.of(mapper.findByItem(id,postName,userName,startDate,endDate));
        return info;
    }

    @Override
    public PostBean findById(int id) {
        return null;
    }
}
